package com.zeng.service.impl;

import com.zeng.entity.Complaints;
import com.zeng.dao.ComplaintsDao;
import com.zeng.service.ComplaintsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Complaints)表服务实现类
 *
 * @author zengfanchao
 * @since 2021-03-30 14:49:42
 */
@Service("complaintsService")
public class ComplaintsServiceImpl implements ComplaintsService {
    @Resource
    private ComplaintsDao complaintsDao;

    /**
     * 通过ID查询单条数据
     *
     * @param complaintsid 主键
     * @return 实例对象
     */
    @Override
    public Complaints queryById(Integer complaintsid) {
        return this.complaintsDao.queryById(complaintsid);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<Complaints> queryAllByLimit(int offset, int limit) {
        return this.complaintsDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param complaints 实例对象
     * @return 实例对象
     */
    @Override
    public Complaints insert(Complaints complaints) {
        this.complaintsDao.insert(complaints);
        return complaints;
    }

    /**
     * 修改数据
     *
     * @param complaints 实例对象
     * @return 实例对象
     */
    @Override
    public Complaints update(Complaints complaints) {
        this.complaintsDao.update(complaints);
        return this.queryById(complaints.getComplaintsid());
    }

    /**
     * 通过主键删除数据
     *
     * @param complaintsid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer complaintsid) {
        return this.complaintsDao.deleteById(complaintsid) > 0;
    }

    @Override
    public List<Complaints> selectAll() {
        return this.complaintsDao.selectAll();
    }

    @Override
    public int queryCount() {
        return this.complaintsDao.queryCount();
    }

    @Override
    public int queryCountSelect(String key) {
        return this.complaintsDao.queryCountSelect(key);
    }

    @Override
    public List<Complaints> queryKeyByLimit(String key, Integer offset, Integer limit) {
        return this.complaintsDao.queryKeyByLimit(key, offset, limit);
    }

    @Override
    public List<Complaints> queryAll(Complaints complaints) {
        return this.complaintsDao.queryAll(complaints);
    }

}
